package com.novel.controller.novel;


import com.novel.common.vo.Chapter;
import com.novel.controller.other.BaseController;
import com.novel.pojo.novel.NovelChapter;
import com.novel.service.NovelChapterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("novel/chapter")
public class NovelChapterController extends BaseController {

    @Autowired
    private NovelChapterService chapterService;

    /**
     * 根据章节id查询章节内容
     *
     * @param id 章节id
     */
    @GetMapping("/{id}")
    public Chapter findChapterById(@PathVariable("id") String id) {
        return chapterService.findChapterById(id);
    }

    /**
     * 根据小说id查询章节列表
     *
     * @param novelId 小说id
     */
    @GetMapping("list/{id}")
    public List<NovelChapter> findChapterListById(@PathVariable("id") String novelId) {
        return chapterService.findChapterList(novelId);
    }

}
